package com.feisuanyz.controller;

import com.feisuanyz.dto.OperationLogDTO;
import com.feisuanyz.query.OperationLogQuery;
import com.feisuanyz.rest.RestResult;
import com.feisuanyz.service.OperationLogService;
import jakarta.validation.Valid;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/operation-log")
public class OperationLogController {

    @Autowired
    private OperationLogService operationLogService;

    @PostMapping("/event")
    public RestResult<Void> logEventOperation(@RequestParam Integer eventId,
                                              @RequestParam String operationType,
                                              @RequestParam String details,
                                              @RequestParam Integer createBy) {
        return operationLogService.logEventOperation(eventId, operationType, details, createBy);
    }

    @PostMapping("/ticket")
    public RestResult<Void> logTicketOperation(@RequestParam Integer ticketId,
                                              @RequestParam String operationType,
                                              @RequestParam String details,
                                              @RequestParam Integer createBy) {
        return operationLogService.logTicketOperation(ticketId, operationType, details, createBy);
    }

    @GetMapping("/event")
    public RestResult<List<OperationLogDTO>> getEventOperationLogs(@Valid @ModelAttribute OperationLogQuery query) {
        return operationLogService.getEventOperationLogs(query);
    }

    @GetMapping("/ticket")
    public RestResult<List<OperationLogDTO>> getTicketOperationLogs(@Valid @ModelAttribute OperationLogQuery query) {
        return operationLogService.getTicketOperationLogs(query);
    }
}